<?php
	global $wpdb;
    $prefix = $wpdb->prefix;
    $meta_boxes = array();
    // First Meta_box
    ## xu ly cac trang dac biet
    
    function check_setpage($mypages,$pageID)
    {
	    foreach ($mypages as $value) 
	    {
	    	$pages = get_page_by_path($value);
	    	if($pages->ID==$pageID)
	    		return 'page';
	    }
	    return 'pages';
    }
    $mypages = array('flights','trains','cars');    
    $pageID = $_GET['post'];
    $apage = check_setpage($mypages, $pageID);  
     
    if(!isset($_SESSION['mycustomer']))
    {
    	if($apage=="page")
    		$_SESSION['mycustomer'] = 'page';
    	else 
    		$_SESSION['mycustomer'] = 'pages';
    			
    }	
    else 
    {
    	if($apage=='page' || $_SESSION['mycustomer']== 'page')
    		$_SESSION['mycustomer'] = 'page';
    	else 	
    		$_SESSION['mycustomer'] = 'pages';
    }    
    $apage = $_SESSION['mycustomer'];
    //print_r($apage);
    	$meta_boxes[] = array(
        'title'     =>  'Add summary infomation',
        'id'        =>  'addition_my_pages',
        'pages'     =>  array($apage),    	  	
        'context'   =>  'normal',
        'priority'  =>  'high',    	    	
        'fields'    =>  array(
	    		array(            	
	                'type'  =>  'image',                       // checkbox
	                'id'    =>  $prefix . 'thumbnail',
	                'name'  =>  '<span style="font-weight: bold;">Upload more images</span>',			
	                'desc'  =>  'Upload more images  size:151x100px <br/>                
	                '
	            ),
	    		array(
					'name' => '<span style="font-weight: bold;">Display</span>',
					'id' => $prefix . 'display',
					'type' => 'radio',              // File type: radio box
					'options' => array(             // Array of 'key' => 'value' pairs for radio options. Note: the 'key' is stored in meta field, not the 'value'
						'display' => 'Display',
						'hidden' => 'Hidden'
					),
					'std' => 'display',
					'desc' => 'Display or hidden.'
				)                      
	        )
	    );
   
	    
   ##-----------------------------------------------------------------
    $meta_boxes[] = array(
        'title'     =>  'Add summary infomation',
        'id'        =>  'addition_ticket',
        'pages'     =>  array('ticket'),
        'context'   =>  'normal',
        'priority'  =>  'high',
        'fields'    =>  array(
    		array(            	
                'type'  =>  'image',                       // checkbox
                'id'    =>  $prefix . 'thumbnail',
                'name'  =>  '<span style="font-weight: bold;">Upload thumbnail</span>',			
                'desc'  =>  'Upload image thumbnail size:410x250px <br/>                
                '
            ),
            array(            	
                'type'  =>  'image',                       // checkbox
                'id'    =>  $prefix . 'thumbnail2',
                'name'  =>  '<span style="font-weight: bold;">Image area ticket</span>',			
                'desc'  =>  'Upload list image area ticket size:150x100px <br/>                
                '
            ),
    		array(
				'name' => '<span style="font-weight: bold;">Display</span>',
				'id' => $prefix . 'display',
				'type' => 'radio',              // File type: radio box
				'options' => array(             // Array of 'key' => 'value' pairs for radio options. Note: the 'key' is stored in meta field, not the 'value'
					'display' => 'Display',
					'hidden' => 'Hidden'
				),
				'std' => 'display',
				'desc' => 'Display or hidden.'
			)                      
        )
    );
    
    
    $meta_boxes[] = array(
        'title'     =>  'Add summary infomation',
        'id'        =>  'addition_news_event',
        'pages'     =>  array('news-event'),
        'context'   =>  'normal',
        'priority'  =>  'high',
        'fields'    =>  array(
    		array(            	
                'type'  =>  'image',                       // checkbox
                'id'    =>  $prefix . 'thumbnail',
                'name'  =>  '<span style="font-weight: bold;">Upload thumbnail</span>',			
                'desc'  =>  'Upload image thumbnail size:135x100px <br/>                
                '
            ),
    		array(
				'name' => '<span style="font-weight: bold;">Display</span>',
				'id' => $prefix . 'display',
				'type' => 'radio',              // File type: radio box
				'options' => array(             // Array of 'key' => 'value' pairs for radio options. Note: the 'key' is stored in meta field, not the 'value'
					'display' => 'Display',
					'hidden' => 'Hidden'
				),
				'std' => 'display',
				'desc' => 'Display or hidden.'
			)                      
        )
    ); 
    
   $meta_boxes[] = array(
        'title'     =>  'Add more infomation',
        'id'        =>  'addition_partner',
        'pages'     =>  array('partner'),
        'context'   =>  'normal',
        'priority'  =>  'high',
        'fields'    =>  array(
   			array(            	
                'type'  =>  'text',                       // checkbox
                'id'    =>  $prefix . 'url',
                'name'  =>  '<span style="font-weight: bold;">Link to site</span>',			
                'desc'  =>  'Enter [other site path] ex: http://example.com'
            ),
    		array(            	
                'type'  =>  'image',                       // checkbox
                'id'    =>  $prefix . 'thumbnail',
                'name'  =>  '<span style="font-weight: bold;">Upload thumbnail</span>',			
                'desc'  =>  'Upload thumbnail size: 71x60px'
            ),
    		array(
				'name' => '<span style="font-weight: bold;">Display on sidebar</span>',
				'id' => $prefix . 'display',
				'type' => 'radio',              // File type: radio box
				'options' => array(             // Array of 'key' => 'value' pairs for radio options. Note: the 'key' is stored in meta field, not the 'value'
					'display' => 'Display on sidebar',
					'hidden' => 'Hidden'
				),
				'std' => 'hidden',
				'desc' => 'Display or Hidden.'
			)                      
        )
    );
    
    // Banner
    $meta_boxes[] = array(
        'title'     =>  'Add more infomation',
        'id'        =>  'addition_Banner',
        'pages'     =>  array('banner'),
        'context'   =>  'normal',
        'priority'  =>  'high',
        'fields'    =>  array(
   			array(            	
                'type'  =>  'text',                       // checkbox
                'id'    =>  $prefix . 'url',
                'name'  =>  '<span style="font-weight: bold;">Link to site</span>',			
                'desc'  =>  'Enter [other site path] ex: http://example.com'
            ),
    		array(            	
                'type'  =>  'image',                       // checkbox
                'id'    =>  $prefix . 'thumbnail',
                'name'  =>  '<span style="font-weight: bold;">Upload Banner</span>',			
                'desc'  =>  'Upload Banner size: 554x106px'
            ),
    		array(
				'name' => '<span style="font-weight: bold;">Display</span>',
				'id' => $prefix . 'display',
				'type' => 'radio',              // File type: radio box
				'options' => array(             // Array of 'key' => 'value' pairs for radio options. Note: the 'key' is stored in meta field, not the 'value'
					'display' => 'Display',
					'hidden' => 'Hidden'
				),
				'std' => 'display',
				'desc' => 'Display or Hidden.'
			)                      
        )
    );
    
    $meta_boxes[] = array(
        'title'     =>  'Add more infomation',
        'id'        =>  'addition_testimonial',
        'pages'     =>  array('testimonial'),
        'context'   =>  'normal',
        'priority'  =>  'high',
        'fields'    =>  array(
    		array(            	
                'type'  =>  'image',                       // checkbox
                'id'    =>  $prefix . 'thumbnail',
                'name'  =>  '<span style="font-weight: bold;">Upload thumbnail</span>',			
                'desc'  =>  'Upload thumbnail size: 86x75px'
            ),
    		array(
				'name' => '<span style="font-weight: bold;">Display</span>',
				'id' => $prefix . 'display',
				'type' => 'radio',              // File type: radio box
				'options' => array(             // Array of 'key' => 'value' pairs for radio options. Note: the 'key' is stored in meta field, not the 'value'
					'display' => 'Display',
					'hidden' => 'Hidden'
				),
				'std' => 'display',
				'desc' => 'Display or Hidden.'
			)                      
        )
    );
   
    $meta_boxes[] = array(
        'title'     =>  'Add summary infomation',
        'id'        =>  'addition_tour',
        'pages'     =>  array('tour'),
        'context'   =>  'normal',
        'priority'  =>  'high',
        'fields'    =>  array(
    		array(            	
                'type'  =>  'image',                       // checkbox
                'id'    =>  $prefix . 'thumbnail',
                'name'  =>  '<span style="font-weight: bold;">Upload image thumbnail</span>',			
                'desc'  =>  'Upload image thumbnail Size: 190x125px'
            ),
            array(
				'name' => '<span style="font-weight: bold;">Tour Price </span>',
				'id' => $prefix . 'price',
				'type' => 'text',             // File type: select box				
				'std' => 0,         // Default value, can be string (single value) or array (for both single and multiple values)
				'desc' => 'Select the current Price'
			),
            array(
				'name' => '<span style="font-weight: bold;">Destination From </span>',
				'id' => $prefix . 'destination_from',
				'type' => 'select',             // File type: select box
				'options' => db_get_destination_from(),
				'multiple' => true,             // Select multiple values, optional. Default is false.
				'std' => array( 'vn' ),         // Default value, can be string (single value) or array (for both single and multiple values)
				'desc' => 'Select the current Destination From'
			),
            array(
				'name' => '<span style="font-weight: bold;">Destination To </span>',
				'id' => $prefix . 'destination_to',
				'type' => 'select',             // File type: select box
				'options' => db_get_destination_from(),
				'multiple' => true,             // Select multiple values, optional. Default is false.
				'std' => array( 'vn' ),         // Default value, can be string (single value) or array (for both single and multiple values)
				'desc' => 'Select the current Destination To'
			),
             
            array(            	
                'type'  =>  'text',                       // checkbox
                'id'    =>  $prefix . 'lenght_of_stay',
                'name'  =>  '<span style="font-weight: bold;">Lenght of Stay</span>',			
                'desc'  =>  'Lenght of Stay'
            ),            			
    		array(
				'name' => '<span style="font-weight: bold;">Display</span>',
				'id' => $prefix . 'display',
				'type' => 'radio',              // File type: radio box
				'options' => array(             // Array of 'key' => 'value' pairs for radio options. Note: the 'key' is stored in meta field, not the 'value'
					'display' => 'Display',
					'hidden' => 'Hidden'
				),
				'std' => 'display',
				'desc' => 'Display / Hidden.'
			),
			array(
				'name' => '<span style="font-weight: bold;">Tour Best</span>',
				'id' => $prefix . 'tour_best',
				'type' => 'radio',              // File type: radio box
				'options' => array(             // Array of 'key' => 'value' pairs for radio options. Note: the 'key' is stored in meta field, not the 'value'
					'display' => 'Display Tour Best',
					'hidden' => 'Hidden Tour Best'
				),
				'std' => 'hidden',
				'desc' => 'Display / Hidden.'
			),
			array(
				'name' => '<span style="font-weight: bold;">Tour Plans Day</span>',
				'id' => $prefix . 'plans',
				'type' => 'wysiwyg',             // Field type: WYSIWYG editor				
				'desc' => 'Enter Tour plans',
			),
			array(
				'name' => '<span style="font-weight: bold;">Tour Inclusive</span>',
				'id' => $prefix . 'inclusive',
				'type' => 'wysiwyg',             // Field type: WYSIWYG editor				
				'desc' => 'Enter tour Inclusive',
			),
			array(
				'name' => '<span style="font-weight: bold;">Tour Exclusive</span>',
				'id' => $prefix . 'exclusive',
				'type' => 'wysiwyg',             // Field type: WYSIWYG editor				
				'desc' => 'Enter tour Exclusive',
			)                      
        )
    );
    
    $meta_boxes[] = array(
        'title'     =>  'Add summary infomation',
        'id'        =>  'addition_hotel',
        'pages'     =>  array('post'),
        'context'   =>  'normal',
        'priority'  =>  'high',
        'fields'    =>  array(
    		array(            	
                'type'  =>  'image',                       // checkbox
                'id'    =>  $prefix . 'thumbnail',
                'name'  =>  '<span style="font-weight: bold;">Upload image thumbnail</span>',			
                'desc'  =>  'Upload image thumbnail Size:w: 241 H: 215 '
            ),            
            array(            	
                'type'  =>  'image',                       // checkbox
                'id'    =>  $prefix . 'thumbnail2',
                'name'  =>  '<span style="font-weight: bold;">Upload more image fore Hotel </span>',			
                'desc'  =>  'Upload more image fore Hotel Size: W: 295 H:180'
            ),
            array(            	
                'type'  =>  'text',                       // checkbox
                'id'    =>  $prefix . 'address',
                'name'  =>  '<span style="font-weight: bold;">Address</span>',			
                'desc'  =>  'Enter Address'
            ),
            array(
				'name' => '<span style="font-weight: bold;">Hotel Price </span>',
				'id' => $prefix . 'price',
				'type' => 'text',             // File type: select box			
				'std' => 0,         // Default value, can be string (single value) or array (for both single and multiple values)
				'desc' => 'Enter the current Price'
			),            
            array(
				'name' => '<span style="font-weight: bold;">Rating</span>',
				'id' => $prefix . 'rating',
				'type' => 'radio',              // File type: radio box
				'options' => array(             // Array of 'key' => 'value' pairs for radio options. Note: the 'key' is stored in meta field, not the 'value'
					'1' => '1 Star',
					'2' => '2 Star',
            		'3' => '3 Star',
            		'4' => '4 Star',
            		'5' => '5 Star'
				),
				'std' => '2',
				'desc' => 'Choosen current Star'
			),
			array(
				'name' => 'Internet Booking',
				'id' => $prefix . 'internet_booking',
				'type' => 'wysiwyg',             // Field type: WYSIWYG editor				
				'desc' => 'Enter Internet booking',
			),
			array(
				'name' => 'Hotel Features',
				'id' => $prefix . 'hotel_feature',
				'type' => 'wysiwyg',             // Field type: WYSIWYG editor				
				'desc' => 'Enter Hotel Features',
			),
			array(
				'name' => 'Hotel Policies',
				'id' => $prefix . 'hotel_policies',
				'type' => 'wysiwyg',             // Field type: WYSIWYG editor				
				'desc' => 'Enter Hotel Policies',
			),			
			array(
				'name' => '<span style="font-weight: bold;">Hotel Best</span>',
				'id' => $prefix . 'hotel_best',
				'type' => 'radio',              // File type: radio box
				'options' => array(             // Array of 'key' => 'value' pairs for radio options. Note: the 'key' is stored in meta field, not the 'value'
					'display' => 'Display Hotel Best',
					'hidden' => 'Hidden Hotel Best'
				),
				'std' => 'hidden',
				'desc' => 'Display / Hidden.'
			),             			
    		array(
				'name' => '<span style="font-weight: bold;">Display</span>',
				'id' => $prefix . 'display',
				'type' => 'radio',              // File type: radio box
				'options' => array(             // Array of 'key' => 'value' pairs for radio options. Note: the 'key' is stored in meta field, not the 'value'
					'display' => 'Display',
					'hidden' => 'Hidden'
				),
				'std' => 'display',
				'desc' => 'Display / Hidden.'
			)			                     
        )
    );
    ##===========================================================================================
     $meta_boxes[] = array(
        'title'     =>  'Addition summary infomation',
        'id'        =>  'addition_slideshow',
        'pages'     =>  array('slide-show'),
        'context'   =>  'normal',
        'priority'  =>  'high',
        'fields'    =>  array(
    		array(            	
                'type'  =>  'text',                       // checkbox
                'id'    =>  $prefix . 'url',
                'name'  =>  '<span style="font-weight: bold;">Link to site</span>',			
                'desc'  =>  'Enter other link to site (Ex: http://)'
            ),
            array(            	
                'type'  =>  'image',                       // checkbox
                'id'    =>  $prefix . 'thumbnail',
                'name'  =>  '<span style="font-weight: bold;">Image thumbnail</span>',			
                'desc'  =>  'Upload Image thumbnail  Kích cỡ: 681x322 px'
            ),
    		array(
				'name' => '<span style="font-weight: bold;">Display Image</span>',
				'id' => $prefix . 'display',
				'type' => 'radio',              // File type: radio box
				'options' => array(             // Array of 'key' => 'value' pairs for radio options. Note: the 'key' is stored in meta field, not the 'value'
					'display' => 'Display',
					'hidden' => 'Hidden'
				),
				'std' => 'display',
				'desc' => 'Display or Hidden .'
			)                      
        )
    );
    
    ##===========================================================================================
     $meta_boxes[] = array(
        'title'     =>  'Addition summary infomation',
        'id'        =>  'addition_slideshow',
        'pages'     =>  array('adv'),
        'context'   =>  'normal',
        'priority'  =>  'high',
        'fields'    =>  array(
    		array(            	
                'type'  =>  'text',                       // checkbox
                'id'    =>  $prefix . 'url',
                'name'  =>  '<span style="font-weight: bold;">Link to site</span>',			
                'desc'  =>  'Enter other link to site (Ex: http://)'
            ),
            array(            	
                'type'  =>  'text',                       // checkbox
                'id'    =>  $prefix . 'discount',
                'name'  =>  '<span style="font-weight: bold;">Discount</span>',			
                'desc'  =>  'Enter Discount (10,15,20...)->(10%,15%,20%...): <b>Only Show on sidebar</b>'
            ),
            array(            	
                'type'  =>  'image',                       // checkbox
                'id'    =>  $prefix . 'thumbnail',
                'name'  =>  '<span style="font-weight: bold;">Image thumbnail</span>',			
                'desc'  =>  '<span style="color:red;">Upload Image thumbnail show on sidebar Kích cỡ: 222x122 px.</span>'
            ),
    		array(
				'name' => '<span style="font-weight: bold;">Display Image gallery (Page Index )</span>',
				'id' => $prefix . 'display',
				'type' => 'radio',              // File type: radio box
				'options' => array(             // Array of 'key' => 'value' pairs for radio options. Note: the 'key' is stored in meta field, not the 'value'
					'display' => 'Display gallery',
					'hidden' => 'Hidden'
				),
				'std' => 'hidden',
				'desc' => '<span style="color:red;">Display Gallery (Page Index)-> Upload images Size:190x144px .</span>'
			),
			array(
				'name' => '<span style="font-weight: bold;">Display Image Next News (Page Index)</span>',
				'id' => $prefix . 'adv_news',
				'type' => 'radio',              // File type: radio box
				'options' => array(             // Array of 'key' => 'value' pairs for radio options. Note: the 'key' is stored in meta field, not the 'value'
					'display' => 'Display',
					'hidden' => 'Hidden'
				),
				'std' => 'hidden',
				'desc' => '<span style="color:red;">Display Image Next News (Page Index) -> Upload images Size:249x195px .</span>'
			),
			array(
				'name' => '<span style="font-weight: bold;">Display Image Next Footer (Page Index)</span>',
				'id' => $prefix . 'adv_footer',
				'type' => 'radio',              // File type: radio box
				'options' => array(             // Array of 'key' => 'value' pairs for radio options. Note: the 'key' is stored in meta field, not the 'value'
					'display' => 'Display',
					'hidden' => 'Hidden'
				),
				'std' => 'hidden',
				'desc' => '<span style="color:red;">Display Image Next Footer (Page Index) -> Upload images Size:674x181px .</span>'
			),
			array(
				'name' => '<span style="font-weight: bold;">Display</span>',
				'id' => $prefix . 'display2',
				'type' => 'radio',              // File type: radio box
				'options' => array(             // Array of 'key' => 'value' pairs for radio options. Note: the 'key' is stored in meta field, not the 'value'
					'display' => 'Display',
					'hidden' => 'Hidden'
				),
				'std' => 'display',
				'desc' => 'Display or Hidden.'
			)                      
        )
    );
    
        
    /*
	## ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
    foreach ($meta_boxes as $meta_box) {
    	new RW_Meta_Box_Taxonomy($meta_box);
    }
    */
?>